package com.lujieni.springbootrocketmq.service;

import com.lujieni.springbootrocketmq.dto.OrderDTO;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
@RocketMQMessageListener(
    topic = "test-topic",                 // 监听的 Topic
    consumerGroup = "my-consumer-group",  // 消费者组
        selectorExpression = "lujieni",   // 只消费 tag = a 的消息,tag的匹配是消费者客户端进行匹配的
        maxReconsumeTimes = 3             // 一个队列有多个线程
)
public class MessageConsumer implements RocketMQListener<OrderDTO> {

    @Override
    public void onMessage(OrderDTO OrderDTO) {
        System.out.println("prepare consume time:"+new Date() + "message:"+OrderDTO);
        // 业务处理逻辑
    }

}